package com.gangan.controller.web;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gangan.controller.common.BaseController;
import com.gangan.model.ActivityApply;
import com.gangan.model.CmsContent;
import com.gangan.service.IActivityApplyService;
import com.gangan.service.ICmsContentService;
import com.gangan.tools.MessageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "*活动报名模块模块控制层")
@RestController
@RequestMapping("/activityApply")
public class ActivityApplyController extends BaseController {

    @Autowired
    IActivityApplyService activityApplyService;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ApiOperation(value="数据列表", notes="根据相关条件查询列表数据")
    public MessageBean list(Page page){
        return resultSuccess(activityApplyService.page(page, Wrappers.<ActivityApply>query().lambda().orderByDesc(ActivityApply::getCreateTime)));
    }

    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @ApiOperation(value="移除数据", notes="根据自增主键移除数据")
    public MessageBean del(Integer id){
        return resultSuccess(activityApplyService.removeById(id));
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ApiOperation(value="新增数据", notes="将提交的数据保存到数据库")
    public MessageBean add(ActivityApply add){
        return resultSuccess(activityApplyService.save(add));
    }

    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    @ApiOperation(value="编辑数据", notes="根据主键修改数据")
    public MessageBean edit(ActivityApply edit){
        return resultSuccess(activityApplyService.updateById(edit));
    }


    @RequestMapping(value = "/selectMyActivityListPage",method = RequestMethod.POST)
    @ApiOperation(value="查询用户我的所有活动", notes="查询用户我的所有活动")
    public MessageBean selectMyActivityListPage(Page page){
        return resultSuccess(activityApplyService.selectMyActivityListPage(page));
    }


    @RequestMapping(value = "/selectMyActivityListPageByType",method = RequestMethod.POST)
    @ApiOperation(value="根据参加状态查询用户我的所有活动", notes="根据参加状态查询用户我的所有活动")
    @ApiImplicitParam(paramType="query",name="status",dataType="Integer",required=false,value="参加状态：0：未审核 1: 待参加 2：已完成")
    public MessageBean selectMyActivityListPageByType(Page page,Integer status){
        return resultSuccess(activityApplyService.selectMyActivityListPageByType(page,status));
    }




}
